﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RiderShop.Mobile.Modle.MyAccount;
using RiderShop.Mobile.ServiceEntity.MyAccount;

namespace RiderShop.Mobile.Modle.Purchase
{
    public class OrderCompletedModel
    {
        public OrderCompletedModel(string parameter)
        {
            if (string.IsNullOrEmpty(parameter) || !parameter.Contains(","))
            {
                return;
            }
            var str = parameter.Split(',');
            //if (str.Length == 3)
            //{
            //    OrderNumber = str[0];
            //    OrderPayAmount = Convert.ToDecimal(str[1]);
            //    //ArrivePay = false; //支付宝
            //    ArrivePay = str[2] == "1";
            //}

            OrderNumber = str[0];

            //Add by dexter to fix amount not contail shipping fee
            OrderBasicInfoExtend order = OrderModel.GetOrderDetailInfo(OrderNumber);
            ArrivePay = order.ArrivePay == 1;
            OrderPayAmount = order.OrderPayAmount;
            IsPayCompleted = order.OrderExpensePoint == OrderPayAmount;
            if (!string.IsNullOrEmpty(order.PaymentGateway))
            {
                switch (order.PaymentGateway.ToUpper())
                {
                    case "WEIXINPAY":
                        PaymnetName = "WEIXINPAY";
                        break;
                    case "ALIPAY":
                        PaymnetName = "ALIPAY";
                        break;
                    case "RONGJICART":
                        PaymnetName = "RONGJICART";
                        break;
                    default:
                        PaymnetName = "ALIPAY";
                        break;
                }
            }
            else
            {
                PaymnetName = "ALIPAY";
            }
        }

        public decimal OrderPayAmount { get; set; }

        public bool ArrivePay { get; set; }

        public string PaymnetName { get; set; }

        public string OrderNumber { get; set; }

        public bool IsPayCompleted { get; set; }
        //public bool IsPayCompleted
        //{
        //    get
        //    {
        //        OrderBasicInfoExtend order = OrderModel.GetOrderDetailInfo(OrderNumber);
        //        return order.OrderExpensePoint == OrderPayAmount;
        //    }
        //}
    }
}
